﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace yysAuxiliary
{
    public class Data
    {
        [Description("功能")]
        public enum FS
        {
            /// <summary>
            /// 御灵
            /// </summary>
            [Description("御灵")]
            YL = 0,
            /// <summary>
            /// 御魂
            /// </summary>
            [Description("御魂")]
            YH,
            /// <summary>
            /// 业原火
            /// </summary>
            [Description("业原火")]
            YYH,
            /// <summary>
            /// 结界突破
            /// </summary>
            [Description("结界突破")]
            JJTP
        }

        [Description("游戏界面")]
        public enum GameInterface
        {
            [Description("庭院")]
            Main = 0,
            [Description("探索")]
            TS,
            [Description("战斗")]
            ZD,
            [Description("未知")]
            None
        }

        public const string prikey = "BwIAAACkAABSU0EyAAgAAAEAAQCt3glsPZ4nZj8SI1GOQlNQy+fGxuDBYiy1uagXBVSnfXaYOvcenoikvxOtMImGsJS82gU456itmvO7xejv08SGdjls8C3dJ0c/6CsrP4RtGGzWxYQx5kDQAzRggXi89m/JjEAEvp/lDQU1b8EwnzHZa6mzcIKE+XYYxdXdAFh5Q1IjA81HxjF7lDE86Pr2AosHMUTSJhuyJAD6VGh6AAQ6p9od1edjapVu9ay4gNLQYBre/e4MbHk2eQlDOwSOXvD67VUYFu/DYpc1Rm1GzRBaPeoFap7q+T3bmhdsGKbrkM0UR2mnOCBhplr1/rRf3WVMRKifinFc66zmrl6a/DPvH1qKoiwtP/gMmxYkzfSC5MioKA7f71zqi2wIt0e07hCNQoy8KYn8vg0u7OLnf5sTefS8Eto4C3GaYNGOm+c7t7Sp9dxKXaQuivHpMvQxMOv9AcOFoKt+fjJIGd2A4i3Fz8sbHliXUxoK4qIlxxuafiW/0zk3IcMkaDsMmH4FtvOzxa25LMFBNLdTiFmEeJH1eFL50saMdjLDO0aRHJ4tP1YdJvuoFv4tXjZ++Hs67WpheoU4a+dXVE3hupsgPXSRtV0eW2creCJPlmpjjEUOr5+jvcr30tTffJpz/+n9e4tT4n4fVwrmD7DN1J3BznF0qMSivZ9kmUSCT6sWFsZD++n9/RmsT5z1LjakiO4SiGXRgMBTxMaaYNg1cta6k9YXCyZ1hjFfdXNCnr3uwomPVf4+Xnmi8JoOayRkUXuMh7uzRiC/cmlFoDVBJt33dgbUErxCiMJdHaQoATbGhw9YsgLOYDkgFrEy98CwqpwrNpzOLdnbZ1Nlw1nfLTCXUs3tP9R7nhD/dsT+BLn6/YqOCAbGpaHBQewT7YC7tZcsZRr3zaXj8dylwAlJE6uW+pkQoLqUymBrO+e5M5l9hLvt+uLerk9a8jMGH6pMxK+gbe5Ic0urrbi6x0wXU9WVJqxpIYf7vxYoLhIsMbwd3X/73k7q3hiCSZID1tEceqS0kqYxqpPhAh0bI+bmyIkMuaDChFwI4fMf1RFlpVo6JkaOCzn1elkvnqXQ8VyS7oiJElRq3Xn38PEIfG32/aY+7ytL8ZF7XRV6zJgGayLM1smt8oXCFkDix1MsXqBS6HW52ABjPnfMagpiZ5X9etzP8gBdsJ6ZTAKb27DPuNwGbop+kCn+mXM3PSkRkW8M1+zLTC8Om5gCQHavxpIkKNJ0xLftnZ652w7NEto+w45F9MnCgxrG3ryNuJmGM63VzHa6tbD6/ZBqAzASt75D/1nf7bHHRtsQrqmvCuCNVe3+lb5BsPEAzAVVeud7gggV8wUGiEwX8XurZPZ9WKhcW1x1Mj35N/mN3UOpyNca05c/0LTQA374KlxHaYFTgxfGH0n5AIbnhgNv3wQAxDr8Px1V/bG5CcaKNI2eQdefuhJXRjiNGi/n9NMEEafrjgeEAlleCh4A+rtt3GO/EgDEKm2i9Rncw72pj5ZEWfHKwswbxHFVRiOWwEFT4Ey3DvLtVu6+5WE=";

        /// <summary>
        /// 当前游戏画面
        /// </summary>
        public static GameInterface IndexGameInterface = GameInterface.None;

        /// <summary>
        /// 当前正在进行的功能
        /// </summary>
        public static FSConfig IndexFS;

        /// <summary>
        /// 当前循环
        /// </summary>
        public static int IndexLoop  = 1;

        /// <summary>
        /// 功能配置集合
        /// </summary>
        public static List<FSConfig> fsList = new List<FSConfig>();

        /// <summary>
        /// 已经执行的集合
        /// </summary>
        public static List<FSConfig> actionedList = new List<FSConfig>();

        /// <summary>
        /// 是否运行
        /// </summary>
        public static bool isRun = true;

        /// <summary>
        /// 阈值
        /// </summary>
        public static float Threshold = 0.98f;


        /// <summary>
        /// 当前token
        /// </summary>
        public static CancellationTokenSource tokenSource;


        /// <summary>
        /// 获取枚举的字段
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string GetEnumDescription<T>(string str) where T : struct
        {
            return EnumDescription<T>.dic[str];
        }
         

        /// <summary>
        /// 授权到期时间
        /// </summary>
        public static DateTime AuthExpireTime = new DateTime(1971, 1, 1);

    }

    /// <summary>
    /// 功能配置
    /// </summary>
    public class FSConfig
    {
        /// <summary>
        /// 功能
        /// </summary>
        public Data.FS fs { get; set; }

        /// <summary>
        /// 执行总次数 
        /// </summary>
        public int Count { get; set; }
    }



    public static class EnumDescription<T> where T : struct
    {
        public static Dictionary<string, string> dic = new Dictionary<string, string>();
        static EnumDescription()
        {
            FieldInfo[] fieldinfos = typeof(T).GetFields();
            foreach (FieldInfo field in fieldinfos)
            {
                if (field.FieldType.IsEnum)
                {
                    Object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false);

                    dic.Add(field.Name, ((DescriptionAttribute)objs[0]).Description);
                }

            }
        }
    }


    /// <summary>
    /// 用于Combox显示绑定的对象
    /// </summary>
    public class BindComboxEnumType<T> where T : struct
    {
        /// <summary>
        /// 类型的名字
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public T Type { get; set; }

        private static readonly List<BindComboxEnumType<T>> bindTyps;

        static BindComboxEnumType()
        {
            bindTyps = new List<BindComboxEnumType<T>>();

            foreach (var name in Enum.GetNames(typeof(T)))
            {
                bindTyps.Add(new BindComboxEnumType<T>()
                {
                    Name = Data.GetEnumDescription<T>(name),
                    Type = (T)Enum.Parse(typeof(T), name)
                });
            }
        }

        /// <summary>
        /// 绑定的类型数据
        /// </summary>
        public static List<BindComboxEnumType<T>> BindTyps
        {
            get { return bindTyps; }
        }
    }


}
